package com.automannn.atm_back.modules.codeGenerator.service.impl;

import com.automannn.atm_back.modules.codeGenerator.entity.TemplateEntity;
import com.automannn.atm_back.modules.codeGenerator.entity.TemplateGroupEntity;
import com.automannn.atm_back.modules.codeGenerator.mapper.TemplateGroupEntityMapper;
import com.automannn.atm_back.modules.codeGenerator.service.TemplateGroupEntityService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * (GeneratorTemplateGroup)表服务实现类
 *
 * @author chenkaihai
 * @since 2020-07-12 17:04:11
 */
@Service
public class TemplateGroupEntityServiceImpl implements TemplateGroupEntityService {
    @Resource
    private TemplateGroupEntityMapper templateGroupEntityMapper;


    /**
     * 查询一个对象
     *
     * @param id return 实例对象
     */
    @Override
    public TemplateGroupEntity queryOne(String id) {
        return this.templateGroupEntityMapper.queryById(id);
    }

    /**
     * 查询所有对象
     * <p>
     * return 实例对象
     */
    @Override
    public IPage<TemplateEntity> queryAll(Page<TemplateGroupEntity> page, TemplateGroupEntity generatorTemplateGroup) {
        return this.templateGroupEntityMapper.queryAll(page, generatorTemplateGroup);
    }

    /**
     * 新增数据
     *
     * @param generatorTemplateGroup 实例对象
     * @return 实例对象
     */
    @Override
    public TemplateGroupEntity insert(TemplateGroupEntity generatorTemplateGroup) {
        this.templateGroupEntityMapper.insert(generatorTemplateGroup);
        return generatorTemplateGroup;
    }

    /**
     * 修改数据
     *
     * @param generatorTemplateGroup 实例对象
     * @return 实例对象
     */
    @Override
    public void update(TemplateGroupEntity generatorTemplateGroup) {
        templateGroupEntityMapper.update(generatorTemplateGroup);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.templateGroupEntityMapper.deleteById(id) > 0;
    }

    @Override
    public void deleteBatchByIds(String ids) {
        templateGroupEntityMapper.deleteBatchIds(Arrays.asList(ids.split(",")));
    }
}
